package cn.huanzi.qch.baseadmin.common.controller;

import cn.huanzi.qch.baseadmin.common.pojo.Result;
import cn.huanzi.qch.baseadmin.util.FileUploadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

/**
 * @author dimples_yj
 * @since 2020-10-10
 */
@Controller
public class FileController {

    @ResponseBody
    @PostMapping("/upload")
    public Result<Map<String, String>> fileUpload(@RequestParam("file") MultipartFile file) throws IOException {
        Map<String, String> map = FileUploadUtil.fileUpload(file);
        return Result.of(map);
    }

}
